<template>
  <!-- 物联网库存 -->
  <div class="outbound">
    <div class="card-search">
      <el-form
        size="small"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="时间">
          <el-date-picker
            v-model="formInline.timeLine"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd HH:mm:00"
            value-format="yyyy-MM-dd HH:mm:00"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="">
          <el-button
            icon="el-icon-search"
            type="primary"
            @click="onSubmit('查询')"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="card-table">
      <el-table
        :header-cell-style="getRowClass"
        :data="tableData"
        style="width: 100%"
      >
        <el-table-column align="center" label="时间" width="120">
          <template slot-scope="{ row }">
            {{ row.createTime.substr(5, 14) }}
          </template>
        </el-table-column>

        <el-table-column
          align="center"
          v-for="(headerName, index) in tableHeader"
          :key="index"
          width="width"
        >
          <template slot="header" slot-scope="">
            <div class="tableHead">{{ headerName }}</div>
          </template>
          <template slot-scope="{ row }">
            <div>
              {{
                row.DTUDataDetail[index] ? row.DTUDataDetail[index].value : "--"
              }}
            </div>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <div class="pagin">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageSize"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="currPage"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import { formMixData } from "@/api/smallCalcination/index.js";
export default {
  name: "cruciblesContent",
  components: {},
  data() {
    return {
      total: "",
      pageSize: 1,
      currPage: 10,
      formInline: {
        time: "Min",
        timeLine: null,
      },
      tableHeader: [
        "晾料锅",
        "晾料皮带",
        "总混捏",
        "东混皮带",
        "西混皮带",
        "挤压压力",
        "抽真空",
        "东干混",
        "西干混",
        "东湿混",
        "西湿混",
        "料室区",
        "变形区",
      ],
      tableData: [],
    };
  },
  computed: {},

  watch: {},
  created() {},
  mounted() {
    this.getAllData();
  },
  methods: {
    async getAllData() {
      if (this.formInline.timeLine === null)
        this.formInline.timeLine = ["", ""];
      const params = {
        pageSize: this.pageSize,
        currPage: this.currPage,
        startTime: this.formInline.timeLine[0],
        endTime: this.formInline.timeLine[1],
        interval: 1,
      };
      let {
        data: { data },
      } = await formMixData(params);
      this.tableData = data.data;
      console.log(this.tableData, "123");
      this.modifyArray(this.tableData)
      this.total = data.total;
    },
    modifyArray(arr) {
      for (let index = 0; index < arr.length; index++) {
        // arr[index].DTUDataDetail.splice(12, 4);
        let arr1 = arr[index].DTUDataDetail.pop()
        console.log(arr1,"这是arr1");
        arr[index].DTUDataDetail.splice(2,0,arr1)
      }
    },

    onSubmit(a) {
      if (a === "查询") this.pageSize = 1;
      this.getAllData();
      // this.$message({
      //   message: "查询成功",
      //   type: "success",
      // });
    },

    handleSizeChange(val) {
      this.currPage = val;
      this.getAllData();
    },
    handleCurrentChange(val) {
      this.pageSize = val;
      this.getAllData();
    },
  },
};
</script>

<style  scoped>
.pagin {
  display: flex;
  justify-content: right;
  padding: 12px 12px 0 0;
}
.pagin  .el-pager .active {
  background-color: $primary !important;
}
</style>
